package com.aforce3.trailertracer.particles;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

public class VectorField
{
	static Vector3d[][][] field; 
	static double grainularity;
	
	public static void init(double grainularity, double bounds)
	{
		VectorField.grainularity = grainularity;
		
		int size = (int)(bounds/grainularity);
		field = new Vector3d[size][size][size];
		
		for(int i = 0; i < size; i++)
			for(int j = 0; j < size; j++)
				for(int k = 0; k < size; k++)
					field[i][j][k] = new Vector3d(Math.random(), 1, Math.random());
	}
	
	public static Vector3d getDirection(Point3d point)
	{
		int x = (int)(point.x/grainularity);
		int y = (int)(point.y/grainularity);
		int z = (int)(point.z/grainularity);
		Vector3d result = field[x][y][z];
		return result;
	}
}
